living document:
https://docs.google.com/document/d/1omDa3lDHnNP23T0amVv_oeEuBL7Hl73e/edit#heading=h.gjdgxs
02/05/2022
living document:
https://docs.google.com/document/d/1omDa3lDHnNP23T0amVv_oeEuBL7Hl73e/edit#heading=h.gjdgxs
R online resourcesR for Data Science: https://r4ds.had.co.nz
R packagesReLTER, lterdatasampler, EML )
RStudio (https://www.rstudio.com/products/rstudio/download/)
New Project -> Version Control
Encourages collaboration “out of the box”. https://github.com/micha-silver/ReLTER_demo
Please execute the code before continue the presentation
# Install some standard spatial packages from CRAN
if (!require("sf", quietly = TRUE))
install.packages("sf")
if (!require("terra", quietly = TRUE))
install.packages("terra")
if (!require("knitr", quietly = TRUE))
install.packages("knitr")
if (!require("glue", quietly = TRUE))
install.packages("glue")
if (!require("remotes", quietly = TRUE))
install.packages("remotes")
# package from Bioconductor
if (!require("BiocManager", quietly = TRUE))
install.packages("BiocManager")
BiocManager::install()
BiocManager::install("EBImage")
## Warning: package(s) not installed when version(s) same as current; use `force = TRUE` to ## re-install: 'EBImage'
ReLTER installation# Install the dev version of ReLTER for use new function
if (!require("ReLTER", quietly = TRUE))
remotes::install_github("ropensci/ReLTER", force = TRUE)
## ReLTER is specially drafted for the LTER community.
##
## To contribute to the improvement of this package, join the group of
## developers (https://github.com/ropensci/ReLTER).
##
## If you use this package, please cite as:
##
## Alessandro Oggioni, Micha Silver, Luigi Ranghetti & Paolo Tagliolato.
## (2021) oggioniale/ReLTER: ReLTER v1.1.0 (1.1.0). Zenodo.
## https://doi.org/10.5281/zenodo.5576813
After installing, we need to load the packages into this R session.
# Convenient way to load list of packages
pkg_list <- c("sf", "terra", "ReLTER", "tmap", "knitr", "glue")
lapply(pkg_list, require, character.only = TRUE)
## [[1]] ## [1] TRUE ## ## [[2]] ## [1] TRUE ## ## [[3]] ## [1] TRUE ## ## [[4]] ## [1] TRUE ## ## [[5]] ## [1] TRUE ## ## [[6]] ## [1] TRUE
R Spatialsf, terraterra, starstmap, leaflet, ggmap, ggplotReLTER relies on the data entered into DEIMS-SDR.
lakeMaggiore <- ReLTER::get_site_info( deimsid = "https://deims.org/f30007c4-8a6e-4f11-ab87-569db54638fe", category = "Boundaries" ) lakeMaggiore
## Simple feature collection with 1 feature and 8 fields ## Geometry type: MULTIPOLYGON ## Dimension: XY ## Bounding box: xmin: 8.47803 ymin: 45.72556 xmax: 8.860755 ymax: 46.18081 ## Geodetic CRS: WGS 84 ## # A tibble: 1 × 9 ## title uri boundaries geoCoord country geoElev.avg geoElev.min ## <chr> <chr> <MULTIPOLYGON [°]> <chr> <list> <dbl> <int> ## 1 Lago… http… (((8.615976 45.72628, 8.… POINT (… <chr> 194. 186 ## # … with 2 more variables: geoElev.max <int>, geoElev.unit <chr>
leaflet::leaflet(lakeMaggiore) %>%
leaflet::addProviderTiles(provider = "CartoDB.PositronNoLabels",
group = "Basemap",
layerId = 123) %>%
leaflet::addTiles("http://{s}.basemaps.cartocdn.com/light_only_labels/{z}/{x}/{y}.png") %>%
leaflet::addPolygons(color = "#444444", weight = 1, smoothFactor = 0.5,
opacity = 1.0, fillOpacity = 0.5)
Following the specification of DEIMS-SDR for each site you can get:
Affiliations
Boundaries
Contacts
EnvCharacts
General
Infrastructure
Parameters
RelateRes
ResearchTop
siteInfo <- ReLTER::get_site_info(
deimsid = "https://deims.org/f30007c4-8a6e-4f11-ab87-569db54638fe",
category = c("Affiliations")
)
knitr::kable(siteInfo$affiliation.projects[[1]])
| label | uri |
|---|---|
| LIFEPLAN | https://cordis.europa.eu/project/id/856506 |
| NETLAKE Cost Action ES1201 | NA |
| eLTER (H2020) | https://cordis.europa.eu/project/id/654359 |
| eLTER PLUS (H2020) - RA | https://cordis.europa.eu/project/id/871128 |
| eLTER PLUS (H2020) - TA | https://cordis.europa.eu/project/id/871128 |
| eLTER PLUS (H2020) - VA | https://cordis.europa.eu/project/id/871128 |
| eLTER catalogue | NA |
Without map
activityNoMap <- ReLTER::get_activity_info( activityid = "https://deims.org/activity/8786fc6d-5d70-495c-b901-42f480182845", show_map = FALSE ) activityNoMap
## Simple feature collection with 1 feature and 12 fields ## Geometry type: POLYGON ## Dimension: XY ## Bounding box: xmin: 17.22656 ymin: 40.46438 xmax: 17.33162 ymax: 40.50408 ## Geodetic CRS: WGS 84 ## # A tibble: 1 × 13 ## title abstract keywords uri type created changed relatedSite ## * <chr> <chr> <list> <chr> <chr> <chr> <chr> <list> ## 1 Study of non-indige… "The in… <df> http… acti… 2021-0… 2021-0… <df> ## # … with 5 more variables: contacts.corresponding <list>, ## # contacts.metadataProvider <list>, boundaries <POLYGON [°]>, ## # observationParameters <lgl>, relatedResources <list>
with map
activityMap <- ReLTER::get_activity_info( activityid = "https://deims.org/activity/8786fc6d-5d70-495c-b901-42f480182845", show_map = TRUE )
The Map of dataset provided by Lake Maggiore
tDataset <- get_dataset_info( datasetid = "https://deims.org/dataset/38d604ef-decb-4d67-8ac3-cc843d10d3ef", show_map = TRUE )
The table about dataset information
tDataset
## Simple feature collection with 1 feature and 33 fields ## Geometry type: POLYGON ## Dimension: XY ## Bounding box: xmin: 11.88721 ymin: 43.20518 xmax: 15.86426 ymax: 45.91294 ## Geodetic CRS: WGS 84 ## # A tibble: 1 × 34 ## title abstract keywords uri type dateRange.from dateRange.to relatedSite ## * <chr> <chr> <list> <chr> <chr> <chr> <lgl> <list> ## 1 LTER No… The pre… <df> http… data… 1965-01-01 NA <df> ## # … with 26 more variables: contacts.corresponding <list>, ## # contacts.creator <list>, contacts.metadataProvider <lgl>, ## # observationParameters <list>, observationSpecies <list>, dataPolicy <list>, ## # doi <chr>, onlineLocation <list>, legal.accessUse <list>, ## # legal.rights <lgl>, legal.legalAct <lgl>, legal.citation <lgl>, ## # method.instrumentation <lgl>, method.qualityAssurance <lgl>, ## # method.methodUrl <list>, method.methodDescription <list>, …
However sometimes there are:
Query for Site Manager
# Multiple sites in the KISKUN region of Hungary
kiskun <- ReLTER::get_ilter_generalinfo(country_name = "Hungary",
site_name = "KISKUN")
# How many sites?
print(paste("In Kiskun region: ", length(kiskun$title), "sites"))
## [1] "In Kiskun region: 8 sites"
(kiskun$title)
## [1] "Kiskun Forest Reserve Sites, KISKUN LTER - Hungary" ## [2] "VULCAN Kiskunsag, KISKUN LTER - Hungary" ## [3] "Kiskun Restoration Experiments, KISKUN LTER - Hungary" ## [4] "Kiskun Site Network (Jedlik), KISKUN LTER - Hungary" ## [5] "KISKUN LTER - Hungary" ## [6] "LTER Fulophaza Site, KISKUN LTER - Hungary" ## [7] "Bugac-Bocsa-Orgovany Site, KISKUN LTER - Hungary" ## [8] "Orgovany Site, KISKUN LTER - Hungary"
# Which site? Bugac-Bocsa bugac_id <- kiskun[7,]$uri bugac_details <- ReLTER::get_site_info(bugac_id,"Contacts") (bugac_details$generalInfo.siteManager[[1]]['name'])
## name ## 1 Gábor Ónodi
Now query for boundary
bugac_polygon <- ReLTER::get_site_info(bugac_id, "Boundaries")
## ## ---- ## This site does not have boundaries uploaded to DEIMS-SDR. ## Please verify in the site page: https://deims.org/609e5959-8cd8-44a0-ab42-eda521cd452a ## ----
str(bugac_polygon)
## tibble [1 × 9] (S3: tbl_df/tbl/data.frame) ## $ title : chr "Bugac-Bocsa-Orgovany Site, KISKUN LTER - Hungary" ## $ uri : chr "https://deims.org/609e5959-8cd8-44a0-ab42-eda521cd452a" ## $ boundaries : logi NA ## $ geoCoord : chr "POINT (19.5281 46.7183)" ## $ country :List of 1 ## ..$ : chr "Hungary" ## $ geoElev.avg : int 112 ## $ geoElev.min : int 105 ## $ geoElev.max : int 120 ## $ geoElev.unit: chr "msl"
# No geometry
paradiso <- ReLTER::get_ilter_generalinfo(country_name = "Italy",
site_name = "Gran Paradiso")
(paradiso$title)
## [1] "IT23 - Gran Paradiso National Park - Italy" ## [2] "Gran Paradiso National Park - Italy"
# Choose the second paradiso_id <- paradiso[2,]$uri paradiso_details <- ReLTER::get_site_info(paradiso_id, "Contacts") # Multiple names for metadata: paradiso_details$generalInfo.metadataProvider[[1]]['name']
## name ## 1 Alessandro Oggioni ## 2 Ramona Viterbi
# But what about funding agency paradiso_details$generalInfo.fundingAgency
## [1] NA
ReLTER has implemented some revealing visualizations of the various parameters collected at LTER sites. One visualization is the pie chart of environmental parameters.
In an example above the DEIMS ID of Kis Balaton (Kiskun LTER) was found. We’ll use that site to show a pie chart of environmental variables collected in that site.
ReLTER::produce_site_parameters_pie("https://deims.org/8129fed1-37b3-48e6-b786-d416917acc72")
## # A tibble: 8 × 4 ## parameterGroups n freq perc ## <chr> <int> <dbl> <chr> ## 1 agricultural parameters 1 0.0208 2% ## 2 atmospheric parameters 1 0.0208 2% ## 3 biological parameters 16 0.333 33% ## 4 chemical parameters 16 0.333 33% ## 5 ecosystem parameters 8 0.167 17% ## 6 physical parameters 1 0.0208 2% ## 7 soil parameters 1 0.0208 2% ## 8 water parameters 4 0.0833 8%
Similarly, a “waffle” chart can be produced.
ReLTER::produce_site_parameters_waffle("https://deims.org/8129fed1-37b3-48e6-b786-d416917acc72")
## # A tibble: 8 × 4 ## parameterGroups n freq label ## <chr> <int> <dbl> <chr> ## 1 agricultural parameters 1 0.0208 2% ## 2 atmospheric parameters 1 0.0208 2% ## 3 biological parameters 16 0.333 33% ## 4 chemical parameters 16 0.333 33% ## 5 ecosystem parameters 8 0.167 17% ## 6 physical parameters 1 0.0208 2% ## 7 soil parameters 1 0.0208 2% ## 8 water parameters 4 0.0833 8%
The produce_site_map function produces a map of the site boundaries, within a given country and network.
tmap::tmap_mode("plot")
# Example of Lake Maggiore site
sitesNetwork <- ReLTER::get_network_sites(
networkDEIMSID = "https://deims.org/network/7fef6b73-e5cb-4cd2-b438-ed32eb1504b3"
)
# In the case of Italian sites are selected only true sites and excluded the
# macrosites.
sitesNetwork <- (sitesNetwork[!grepl('^IT', sitesNetwork$title),])
sf::st_crs(sitesNetwork) = 4326
siteMap <- ReLTER::produce_site_map(
deimsid = "https://deims.org/f30007c4-8a6e-4f11-ab87-569db54638fe",
countryCode = "ITA",
listOfSites = sitesNetwork,
gridNx = 0.7,
gridNy = 0.35
)
The produce_site_qrcode function produces a QRCode of the site (or Activity, Dataset, Network, etc.)
Lake Maggiore
before continue please execute install development version of ReLTER Package
if (!require("ReLTER", quietly = TRUE))
remotes::install_github("ropensci/ReLTER", ref = 'dev__withImprovements', force = TRUE)
Functions within ReLTER help to acquire certain Earth Observation datasets.
The get_site_ODS() function offers to ReLTER users access to the OpenDataScience Europe (ODS) archive (https://maps.opendatascience.eu/) with landcover, NDVI, natura2000, Corine landcover, and OSM features, all at 30 meter pixel resolution. Cropping to site boundaries is done in the cloud, and due to the Cloud Optimized Geotiff (COG) format, downloads are quite small.
# Get DEIMS ID for Kis-Balaton site
kis_balaton <- ReLTER::get_ilter_generalinfo(country_name = "Hungary",
site_name = "Kis-Balaton")
kb_id = kis_balaton$uri
kb_polygon = ReLTER::get_site_info(kb_id, "Boundaries")
# Now acquire landcover and NDVI from ODS
kb_landcover = ReLTER::get_site_ODS(kb_id, dataset = "landcover")
kb_ndvi_summer = ReLTER::get_site_ODS(kb_id, "ndvi_summer")
# Plot maps
tm_basemap("OpenStreetMap.Mapnik") +
tm_shape(kb_polygon) +
tm_borders(col = "purple") +
tm_shape(kb_ndvi_summer) +
tm_raster(alpha=0.7, palette = "RdYlGn")
## Variable(s) "NA" contains positive and negative values, so midpoint is set to 0. Set midpoint = NA to show the full spectrum of the color palette.
tm_basemap("OpenStreetMap.Mapnik") +
tm_shape(kb_polygon) +
tm_borders(col = "purple") +
tm_shape(kb_landcover) +
tm_raster(alpha=0.7, palette = "Set1")
lezirias <- ReLTER::get_ilter_generalinfo(country_name = "Portugal",
site_name = "Companhia")
lezirias_id = lezirias$uri
lezirias_polygon = ReLTER::get_site_info(lezirias_id, "Boundaries")
# Now acquire spring NDVI from OSD
lezirias_ndvi_spring = ReLTER::get_site_ODS(lezirias_id, "ndvi_spring")
# Plot maps
tm_basemap("OpenStreetMap.Mapnik") +
tm_shape(lezirias_polygon) +
tm_borders(col = "purple") +
tm_shape(lezirias_ndvi_spring) +
tm_raster(alpha=0.7, palette = "RdYlGn")
## Variable(s) "NA" contains positive and negative values, so midpoint is set to 0. Set midpoint = NA to show the full spectrum of the color palette.
The function outputs a raster. We can save to Geotiff for use in other GIS
class(lezirias_ndvi_spring)
## [1] "SpatRaster" ## attr(,"package") ## [1] "terra"
writeRaster(x = lezirias_ndvi_spring,
filename = "lezirias_ndvi_spring.tif",
overwrite = TRUE)
List all research topics throughout an LTER network.
List related resources for an LTER network.
We demonstrate with the LTER network in Slovakia. Then filter for “Ecosystem” research.
lter_slovakia_id <- "https://deims.org/networks/3d6a8d72-9f86-4082-ad56-a361b4cdc8a0"
slv_research_topics <- ReLTER::get_network_research_topics(lter_slovakia_id)
ecosystem_items <- grepl(pattern = "ecosystem",
slv_research_topics$researchTopicsLabel,
fixed = TRUE)
# Here is the filtered list
knitr::kable(slv_research_topics[ecosystem_items,])
| researchTopicsLabel | researchTopicsUri |
|---|---|
| ecosystem ecology | http://vocabs.lter-europe.net/EnvThes/21689 |
| ecosystem function | http://vocabs.lter-europe.net/EnvThes/20519 |
| ecosystem service | http://vocabs.lter-europe.net/EnvThes/20520 |
knitr::kable(get_network_related_resources(lter_slovakia_id))
| relatedResourcesTitle | uri | relatedResourcesChanged |
|---|---|---|
| Báb_temperature_precipitation_LTER_EU_SK_001_2014-2018 | https://deims.org/dataset/8f80225a-1250-470b-9092-31d61bde3d44 | 2019-12-20 13:21:00 |
| LTER_Jalovecka dolina temperature 2003-2017 | https://deims.org/dataset/122e06fb-11f3-43a7-abc5-067bb302c92b | 2020-01-07 15:00:00 |
| LTER Jalovecka dolina precipitation 2013-2017 | https://deims.org/dataset/84e13ed2-e353-4e1a-abb3-2cf5d596007e | 2019-12-20 13:21:00 |
| Climate Kralova hola_LTER_EU_SK_009_2015-2018 | https://deims.org/dataset/85d310ab-011a-414c-b90b-3358058dc0cd | 2019-12-20 13:21:00 |
| LTER EES Kremicke vrchy climate | https://deims.org/dataset/ae9ca83c-77b8-493e-9c63-49dcc6a46c5f | 2019-12-20 13:21:00 |
| LTER Polana-Hukavsky_grun temperature precipitation 2011-2017 | https://deims.org/dataset/b7507d3d-0379-4930-a2cb-f8a10b77439b | 2019-12-20 13:21:00 |
| NA | NA | NA |
Functions within ReLTER help to acquire certain third parties biodiversity datasets. The get_site_speciesOccurrences function1, offers to ReLTER users access to the occurrence records from GBIF (via rgbif R package), iNaturalist and OBIS carried out within the boundaries of the site.
Coauthor of these functions are Martina Zilioli and Paolo Tagliolato.
1 get_site_speciesOccurrences, map_occ_gbif2elter and save_occ_eLTER_reporting_Archive currently are delivered only with dev__withImprovements branch of ReLTER
# DEIMS.iD of eLTER site Gulf Of Venice (GOV) GOVid <- "https://deims.org/758087d7-231f-4f07-bd7e-6922e0c283fd" resGOV <- ReLTER::get_site_speciesOccurrences( deimsid = GOVid, list_DS = "obis", show_map = TRUE, limit = 10)
# DEIMS.iD of eLTER the Saldur River Catchment site
saldur_id <- "https://deims.org/97ff6180-e5d1-45f2-a559-8a7872eb26b1"
occ_SRC <- ReLTER::get_site_speciesOccurrences(
deimsid = saldur_id, list_DS = c("gbif", "inat"), show_map = TRUE, limit = 100)
Fields mapping among the three data source schemas (i.e., GBIF, iNaturalist, OBIS) and the eLTER data-reporting template (Peterseil et al., 2021) was carried out so as to design ReLTER functions: map_occ_gbif2elter and save_occ_eLTER_reporting_Archive.
Below an example of iNaturalist export data, for the Saldur River Catchment site.
library(dplyr)
saldurid <- "https://deims.org/97ff6180-e5d1-45f2-a559-8a7872eb26b1"
resSaldur <- ReLTER::get_site_speciesOccurrences(
deimsid = saldurid, list_DS = c("gbif", "inat"), show_map = FALSE, limit = 20,
exclude_inat_from_gbif = TRUE)
# iNaturalist
tblSaldur_inat <- tibble::as_tibble(resSaldur$inat)
outInat <- tblSaldur_inat %>%
ReLTER::map_occ_inat2elter(deimsid = saldurid)
ReLTER::save_occ_eLTER_reporting_Archive(outInat)
The eLTER useful archive created is:
before continue please execute install the last version of ReLTER Package
if (!require("ReLTER", quietly = TRUE))
remotes::install_github("ropensci/ReLTER", force = TRUE)
if (!require("dplyr", quietly = TRUE))
install.packages("dplyr")
library(ReLTER)
library(dplyr)
This example uses the LTER network in Greece. Call the produce_network_points_map() function (requires both DEIMS network ID and the three letter ISO code for the country to be mapped) to get all sites in a country.
tmap::tmap_mode("view")
## tmap mode set to interactive viewing
lter_greece_id = "https://deims.org/networks/83453a6c-792d-4549-9dbb-c17ced2e0cc3" lter_greece <- ReLTER::produce_network_points_map(networkDEIMSID = lter_greece_id, countryCode = "GRC")
grc <- readRDS("gadm36_GRC_0_sp.rds") # available from `produce_network_points_map()
tmap::tm_shape(grc) +
tmap::tm_borders(col = "purple", lwd = 2) +
tmap::tm_grid(alpha = 0.4) +
lter_greece